import time
import unittest
from selenium import  webdriver
from Page.page1 import Page1
import sys
from pathlib import Path
sys.path.append(str(Path(__file__).parent.parent))
from selenium.webdriver.common.by import By


class Test_Case(unittest.TestCase):
    # 测试固件
    def setUp(self):
        self.driver = webdriver.Edge()


    def tearDown(self):
        self.driver.quit()

    # 测试用例
    def test_jiuxian_01(self):

        po = Page1(self.driver)
        po.open_uri('https://www.jiuxian.com/')
        po.login()
        time.sleep(2)
        login_user=self.driver.find_element(By.CLASS_NAME,'userLogin.on').text
        self.assertEqual('帐号登录',login_user)
        print(login_user)
        po.uname()
        po.password()
        time.sleep(15)
        po.save()
        po.accept()
        time.sleep(3)
        login_text = self.driver.find_element(By.XPATH,'/html/body/div[2]/div/div[1]/div/p/span').text
        self.assertEqual('jxw358546243',login_text)
        print(login_text)


if __name__ == '__main__':
    unittest.main()